package com.example.demo.controller;

import com.example.demo.pojo.School;
import com.example.demo.service.SchoolService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * @version 1.0
 * @Author liutao960916@outlook.com
 * @create 2021/6/16 15:36
 */

@CrossOrigin
@RestController
public class SchoolController {
    @Autowired
    SchoolService schoolService;

    /**
     * 查询所有
     *
     * @return
     */
    @RequestMapping(value = "/ListSchool")
    @ResponseBody
    public List<School> ListSchool() {
        return schoolService.ListSchool();
    }

    /**
     * 通过名字查询  模糊查询
     *
     * @param schoolName
     * @return
     */
    @RequestMapping(value = "/ListByName")
    @ResponseBody
    public List<School> ListSchoolByName(String schoolName) {
        return schoolService.findByName(schoolName);
    }

    /**
     * 通过地区查询  模糊查询
     *
     * @param province
     * @return
     */
    @RequestMapping(value = "/ListByProvince")
    @ResponseBody
    public List<School> ListSchoolByProvince(String province) {
        return schoolService.findByProvince(province);
    }

    /**
     * 通过条件查询  模糊查询
     *
     * @param type
     * @return
     */
    @RequestMapping(value = "/ListByType")
    @ResponseBody
    public List<School> ListSchoolByType(String type) {
        return schoolService.findByType(type);
    }

}
